package com.kingyea.kim.trip.controller;

import com.kingyea.kim.base.Result;
import com.kingyea.kim.trip.condition.TripCondition;
import com.kingyea.kim.trip.service.TripService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author lgy
 * @version v1.0.0
 * @description
 * @date Created in 2018/8/20 0020 16:26
 */
@CrossOrigin
@RestController
@RequestMapping("/trip")
public class TripController {
    private final static Logger logger = LoggerFactory.getLogger(TripController.class);

    @Autowired
    private TripService tripService;

    /**
     *@Description 列表显示通过标题或者日期获取对象
     *@Param: [condition]
     *@return: com.kingyea.kim.base.Result
     *@Author: lgy
     *@Date: 2018/8/20 0020
     */
    @RequestMapping(method = RequestMethod.POST, value = "/list")
    @ResponseBody
    public Result list(@RequestBody TripCondition condition){

        return tripService.list(condition);
    }

    /**
     *@Description  添加日程
     *@Param: [trip]
     *@return: com.kingyea.kim.base.Result
     *@Author: lgy
     *@Date: 2018/8/20 0020
     */
    @RequestMapping(method = RequestMethod.POST, value = "/add")
    @ResponseBody
    public Result addTrip(@RequestBody TripCondition trip){
     return tripService.addTrip(trip);
    }

    /**
     *@Description 修改日程状态或者日程信息
     *@Param: [tripCondition]
     *@return: com.kingyea.kim.base.Result
     *@Author: lgy
     *@Date: 2018/8/20 0020
     */
    @RequestMapping(method = RequestMethod.POST, value = "/update")
    @ResponseBody
    public Result updateState(@RequestBody TripCondition tripCondition){
       return tripService.update(tripCondition);
    }

    /**
     *@Description 删除日程
     *@Param: [id]
     *@return: com.kingyea.kim.base.Result
     *@Author: lgy
     *@Date: 2018/8/20 0020
     */
    @RequestMapping(method = RequestMethod.POST, value = "/delete/{id}")
    public Result deleteById(@PathVariable Integer id){
      return tripService.deleteById(id);
    }

    /**
     *@Description 根据id查找对象
     *@Param: [id]
     *@return: com.kingyea.kim.base.Result
     *@Author: lgy
     *@Date: 2018/8/20 0020
     */
    @RequestMapping(method = RequestMethod.POST, value = "/detail/{id}")
    public Result selectById(@PathVariable  Integer id){
       return tripService.selectById(id);
    }
}
